using System;
using System.Windows;
using System.Windows.Media.Animation;
namespace Microsoft.Expression.Interactivity.Media
{
	[CLSCompliant(false)]
	public class ControlStoryboardAction : StoryboardAction
	{
		public static readonly DependencyProperty ControlStoryboardProperty = DependencyProperty.Register("ControlStoryboardOption", typeof(ControlStoryboardOption), typeof(ControlStoryboardAction), null);
		private bool isPaused;
		public ControlStoryboardOption ControlStoryboardOption
		{
			get
			{
				return (ControlStoryboardOption)base.GetValue(ControlStoryboardAction.ControlStoryboardProperty);
			}
			set
			{
				base.SetValue(ControlStoryboardAction.ControlStoryboardProperty, value);
			}
		}
		protected override void OnStoryboardChanged(DependencyPropertyChangedEventArgs args)
		{
			this.isPaused = false;
		}
		protected override void Invoke(object parameter)
		{
			if (base.AssociatedObject != null && base.Storyboard != null)
			{
				switch (this.ControlStoryboardOption)
				{
				case ControlStoryboardOption.Play:
					base.Storyboard.Begin();
					return;
				case ControlStoryboardOption.Stop:
					base.Storyboard.Stop();
					return;
				case ControlStoryboardOption.TogglePlayPause:
				{
					ClockState clockState = 2;
					try
					{
						clockState = base.Storyboard.GetCurrentState();
					}
					catch (InvalidOperationException)
					{
					}
					if (clockState == 2)
					{
						this.isPaused = false;
						base.Storyboard.Begin();
						return;
					}
					if (this.isPaused)
					{
						this.isPaused = false;
						base.Storyboard.Resume();
						return;
					}
					this.isPaused = true;
					base.Storyboard.Pause();
					return;
				}
				case ControlStoryboardOption.Pause:
					base.Storyboard.Pause();
					return;
				case ControlStoryboardOption.Resume:
					base.Storyboard.Resume();
					return;
				case ControlStoryboardOption.SkipToFill:
					base.Storyboard.SkipToFill();
					break;
				default:
					return;
				}
			}
		}
	}
}
